package cn.controller;

import cn.pojo.User;
import cn.repository.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@Slf4j
public class Hello {
    @Autowired
    private UserRepository userRepository;


    @GetMapping("/hello/{id}")
    //@SentinelResource
    public User hello(@PathVariable("id") Integer id){
//        System.out.println("被调用了");
//        try {
//            Thread.sleep(1100);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
        User user = new User();
        user.setId(id);
        User user1 = userRepository.selectOne(user);
        return user1;
    }




}
